package pers.xiaojun.boot.common.validation.constraints;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import pers.xiaojun.boot.common.validation.ArrayValuable;
import pers.xiaojun.boot.common.validation.validator.InEnumValidator;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 限定值在枚举类中
 *
 * @author xiaojun
 * @since 2025-11-01
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@Constraint(validatedBy = InEnumValidator.class)
public @interface InEnum {

    /**
     * @return 实现 ArrayValuable 接口的类
     */
    Class<? extends ArrayValuable<?>> value();

    String message() default "必须在指定范围 {value}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
